home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / sun / volume1 / calentool / patch4b < prev    next >
Encoding:
Internet Message Format  |  1989-10-26  |  55.0 KB

  1. Subject:  v01i073:  Patches for calentool (to patchlevel 4), Part02/04
  2. Newsgroups: comp.sources.sun
  3. Approved: mcgrew@aramis.rutgers.edu
  4.  
  5. Submitted-by: Bill Randle <billr@saab.cna.tek.com>
  6. Posting-number: Volume 1, Issue 73
  7. Archive-name: calentool/patch4b
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 2 (of 4)."
  16. # Contents:  patches04b
  17. # Wrapped by billr@saab on Tue Sep 19 06:29:57 1989
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'patches04b' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'patches04b'\"
  21. else
  22. echo shar: Extracting \"'patches04b'\" \(52733 characters\)
  23. sed "s/^X//" >'patches04b' <<'END_OF_FILE'
  24. X*** /tmp/,RCSt1a05555    Wed Jul 19 20:46:02 1989
  25. X--- moon.c    Wed Jul 19 20:29:00 1989
  26. X***************
  27. X*** 1,5
  28. X  /*
  29. X!  * $Header: moon.c,v 2.1 89/05/09 14:19:22 billr Exp $
  30. X   */
  31. X  /*
  32. X   * moon.c
  33. X
  34. X--- 1,5 -----
  35. X  /*
  36. X!  * $Header: moon.c,v 2.2 89/07/19 20:28:12 billr Exp $
  37. X   */
  38. X  /*
  39. X   * moon.c
  40. X***************
  41. X*** 9,15
  42. X   * Bill Randle, Tektronix, Inc. to interface to the calentool
  43. X   * program.
  44. X   */
  45. X! #include "ct.h"        /* for the NO_SUN_MOON #define */
  46. X  #ifndef NO_SUN_MOON
  47. X  
  48. X  /*
  49. X
  50. X--- 9,15 -----
  51. X   * Bill Randle, Tektronix, Inc. to interface to the calentool
  52. X   * program.
  53. X   */
  54. X! #include "ct.h"     /* for the NO_SUN_MOON #define */
  55. X  #ifndef NO_SUN_MOON
  56. X  
  57. X  /*
  58. X***************
  59. X*** 16,22
  60. X  
  61. X      A Moon for the Sun
  62. X  
  63. X!     Release 2.0
  64. X  
  65. X      Designed and implemented by John Walker in December 1987,
  66. X      revised and updated in February of 1988.
  67. X
  68. X--- 16,22 -----
  69. X  
  70. X      A Moon for the Sun
  71. X  
  72. X!     Release 2.3
  73. X  
  74. X      Designed and implemented by John Walker in December 1987,
  75. X      revised and updated in February of 1988.
  76. X***************
  77. X*** 20,25
  78. X  
  79. X      Designed and implemented by John Walker in December 1987,
  80. X      revised and updated in February of 1988.
  81. X  
  82. X      cc -O moontool.c -o moontool -lm -lsuntool -lsunwindow -lpixrect
  83. X  
  84. X
  85. X--- 20,26 -----
  86. X  
  87. X      Designed and implemented by John Walker in December 1987,
  88. X      revised and updated in February of 1988.
  89. X+     revised and updated again in June of 1988 by Ron Hitchens
  90. X  
  91. X      Make with:
  92. X  
  93. X***************
  94. X*** 21,26
  95. X      Designed and implemented by John Walker in December 1987,
  96. X      revised and updated in February of 1988.
  97. X  
  98. X      cc -O moontool.c -o moontool -lm -lsuntool -lsunwindow -lpixrect
  99. X  
  100. X      Adding  appropriate  floating  point  options  to your hardware.  This
  101. X
  102. X--- 22,29 -----
  103. X      revised and updated in February of 1988.
  104. X      revised and updated again in June of 1988 by Ron Hitchens
  105. X  
  106. X+     Make with:
  107. X+ 
  108. X      cc -O moontool.c -o moontool -lm -lsuntool -lsunwindow -lpixrect
  109. X  
  110. X      Adding  appropriate  floating  point  options  to your hardware.  This
  111. X***************
  112. X*** 75,80
  113. X      program.  Please leave the original attribution information intact    so
  114. X      that credit and blame may be properly apportioned.
  115. X  
  116. X  */
  117. X  
  118. X  /*  Astronomical constants  */
  119. X
  120. X--- 78,147 -----
  121. X      program.  Please leave the original attribution information intact    so
  122. X      that credit and blame may be properly apportioned.
  123. X  
  124. X+    Revision history:
  125. X+ 
  126. X+         1.0  11/5/87   First version.  Only displayed icon, no
  127. X+                        open window information display.
  128. X+ 
  129. X+         2.0  3/27/88   First posting to comp.sources.unix.
  130. X+ 
  131. X+         2.1  6/16/88   Bug fix.  Table of phases didn't update
  132. X+                        at the moment of the new moon.  Call on
  133. X+                        phasehunt didn't convert civil Julian date
  134. X+                        to astronomical Julian date.  Reported by
  135. X+                        Dag Bruck (dag@control.lth.se).
  136. X+ 
  137. X+         2.2  2/27/89   Michael McClary  (michael@xanadu.COM)
  138. X+                        Added moon map, derived from the sun "fullmoon"
  139. X+                        image file.  (It has not been checked for
  140. X+                        rotation from the correct orientation.  Also, a
  141. X+                        fixed icon doesn't model the librations of the
  142. X+                        moon as viewed from the earth.) Also: tweaked
  143. X+                        corners of icon.
  144. X+ 
  145. X+         2.3  6/7/89    Bug fix.  Table of phases skipped the phases
  146. X+                        for July 1989.  This occurred due to sloppy
  147. X+                        maintenance of the synodic month index in the
  148. X+                        interchange of information between phasehunt()
  149. X+                        and meanphase().  I simplified and corrected
  150. X+                        the handling of the month index as phasehunt()
  151. X+                        steps along and removed unneeded code from
  152. X+                        meanphase().  Reported by Bill Randle of
  153. X+                        Tektronix, Inc. (billr@saab.CNA.TEK.COM).
  154. X+ 
  155. X+ Additional History:
  156. X+ 
  157. X+     June 1988    Modified by Ron Hitchens to produce version 2.1
  158. X+             modified icon generation to show surface texture
  159. X+              on visible moon face.  Eliminated "illegal" direct
  160. X+              modification of icon image memory.
  161. X+             added a menu to allow switching in and out of
  162. X+              test mode, for entertainment value mostly.
  163. X+             reworked timer behaviour so that process doesn't
  164. X+              wake up unnecessarily.
  165. X+             trap sigwinch signals to notice more easily when the
  166. X+              tool opens and closes.
  167. X+             modified layout of information in open window display
  168. X+              to reduce the amount of pixels modified in each
  169. X+              update.  Batched pixwin updates so that only one
  170. X+              screen rasterop per cycle is done.
  171. X+             changed open window to display white-on-black for a
  172. X+              more aesthetic look, and to suggest the effect of
  173. X+              looking at the moon in the nighttime sky.
  174. X+             setup default tool and canvas colors to be the same
  175. X+              as B&W monochrome, for those us lucky enough to have
  176. X+              color monitors and who have the default monochrome
  177. X+              colors set to something other than B&W (I like white
  178. X+              on dark blue myself)
  179. X+             various code reformatting and pretty-printing to suit
  180. X+              my own coding taste (I got a bit carried away).
  181. X+             code tweaking to make lint happy.
  182. X+             returned my hacked version to John.
  183. X+ 
  184. X+             Ron Hitchens
  185. X+                 ronbo@vixen.uucp
  186. X+                 ...!uunet!cs.utexas.edu!vixen!ronbo
  187. X+                 hitchens@cs.utexas.edu
  188. X  */
  189. X  
  190. X  
  191. X***************
  192. X*** 77,82
  193. X  
  194. X  */
  195. X  
  196. X  /*  Astronomical constants  */
  197. X  
  198. X  #define epoch        2444238.5       /* 1980 January 0.0 */
  199. X
  200. X--- 144,167 -----
  201. X                  hitchens@cs.utexas.edu
  202. X  */
  203. X  
  204. X+ 
  205. X+ #include <stdio.h>
  206. X+ #include <math.h>
  207. X+ #include <sys/time.h>
  208. X+ 
  209. X+ #include <suntool/sunview.h>
  210. X+ #include <suntool/canvas.h>
  211. X+ 
  212. X+ #define TINYFONT    "/usr/lib/fonts/fixedwidthfonts/screen.r.7"
  213. X+ 
  214. X+ /*
  215. X+  * define standard B/W monochrome colors as defaults in case we're running
  216. X+  * on a color system with the monochrome colors set differently
  217. X+  */
  218. X+ #define FG_DEFAULT    { 0, 0, 0 }        /* black */
  219. X+ #define BG_DEFAULT    { 255, 255, 255 }    /* white */
  220. X+ 
  221. X+ 
  222. X  /*  Astronomical constants  */
  223. X  
  224. X  #define epoch        2444238.5       /* 1980 January 0.0 */
  225. X***************
  226. X*** 80,86
  227. X  /*  Astronomical constants  */
  228. X  
  229. X  #define epoch        2444238.5       /* 1980 January 0.0 */
  230. X! #define    J1970        2440587.5       /* VAX clock Epoch 1970 Jan 1 (0h UT) */
  231. X  
  232. X  /*  Constants defining the Sun's apparent orbit  */
  233. X  
  234. X
  235. X--- 165,171 -----
  236. X  /*  Astronomical constants  */
  237. X  
  238. X  #define epoch        2444238.5       /* 1980 January 0.0 */
  239. X! #define J1970       2440587.5      /* VAX clock Epoch 1970 Jan 1 (0h UT) */
  240. X  
  241. X  /*  Constants defining the Sun's apparent orbit  */
  242. X  
  243. X***************
  244. X*** 114,122
  245. X  
  246. X  #define earthrad    6378.16       /* Radius of Earth in kilometres */
  247. X  
  248. X- #include <stdio.h>
  249. X- #include <math.h>
  250. X- #include <sys/time.h>
  251. X  
  252. X  #include <suntool/sunview.h>
  253. X  #include <suntool/canvas.h>
  254. X
  255. X--- 199,204 -----
  256. X  
  257. X  #define earthrad    6378.16       /* Radius of Earth in kilometres */
  258. X  
  259. X  
  260. X  #define PI 3.14159265358979323846  /* Assume not near black hole nor in
  261. X                        Tennessee */
  262. X***************
  263. X*** 118,174
  264. X  #include <math.h>
  265. X  #include <sys/time.h>
  266. X  
  267. X- #include <suntool/sunview.h>
  268. X- #include <suntool/canvas.h>
  269. X- 
  270. X- /* Icon definition.  This is just a black field with rounded corners
  271. X-    that blend into the root desktop pattern. The image of the moon and
  272. X-    the text are added by the program later. */
  273. X- 
  274. X- static short moon_img[64][4] = {
  275. X- /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */
  276. X-     0x8FFF,0xFFFF,0xFFFF,0xFFE8,0x9FFF,0xFFFF,0xFFFF,0xFFF8,
  277. X-     0x3FFF,0xFFFF,0xFFFF,0xFFFE,0x7FFF,0xFFFF,0xFFFF,0xFFFE,
  278. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  279. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  280. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  281. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  282. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  283. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  284. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  285. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  286. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  287. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  288. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  289. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  290. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  291. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  292. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  293. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  294. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  295. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  296. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  297. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  298. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  299. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  300. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  301. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  302. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  303. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  304. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  305. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x7FFF,0xFFFF,0xFFFF,0xFFFE,
  306. X-     0xFFFF,0xFFFF,0xFFFF,0xFFFE,0xBFFF,0xFFFF,0xFFFF,0xFFFC,
  307. X-     0x3FFF,0xFFFF,0xFFFF,0xFFFA,0x27FF,0xFFFF,0xFFFF,0xFFE2
  308. X- };
  309. X- DEFINE_ICON_FROM_IMAGE(moon_icon, moon_img);
  310. X- mpr_static(icon_mpr, 64, 64, 1, moon_img);
  311. X- 
  312. X- extern Canvas mcanvas;
  313. X- extern Pixfont *font;
  314. X- extern char *monthnames[];
  315. X- static Pixwin *cpw;
  316. X- static int charhgt, charwid;
  317. X- 
  318. X  #define PI 3.14159265358979323846  /* Assume not near black hole nor in
  319. X                        Tennessee */
  320. X  
  321. X
  322. X--- 200,205 -----
  323. X  #define earthrad    6378.16       /* Radius of Earth in kilometres */
  324. X  
  325. X  
  326. X  #define PI 3.14159265358979323846  /* Assume not near black hole nor in
  327. X                        Tennessee */
  328. X  
  329. X***************
  330. X*** 182,188
  331. X  #define dsin(x) (sin(torad((x))))              /* Sin from deg */
  332. X  #define dcos(x) (cos(torad((x))))              /* Cos from deg */
  333. X  
  334. X- /*  Forward functions  */
  335. X  
  336. X  double jtime(), phase();
  337. X  void phasehunt();
  338. X
  339. X--- 213,218 -----
  340. X  #define dsin(x) (sin(torad((x))))              /* Sin from deg */
  341. X  #define dcos(x) (cos(torad((x))))              /* Cos from deg */
  342. X  
  343. X  
  344. X  /*
  345. X   * Moon image.  This is a standard icon-sized picture of the moon's face.
  346. X***************
  347. X*** 184,192
  348. X  
  349. X  /*  Forward functions  */
  350. X  
  351. X! double jtime(), phase();
  352. X! void phasehunt();
  353. X! void drawmoon(), jyear(), jhms();
  354. X  
  355. X  
  356. X  /*  DRAWMOON  --  Construct icon for moon, given phase of moon.  */
  357. X
  358. X--- 214,224 -----
  359. X  #define dcos(x) (cos(torad((x))))              /* Cos from deg */
  360. X  
  361. X  
  362. X! /*
  363. X!  * Moon image.  This is a standard icon-sized picture of the moon's face.
  364. X!  * The visible part, as calculated by the current time, is extracted from
  365. X!  * this image to create the displayed image.
  366. X!  */
  367. X  
  368. X  static short moon_img [] = {
  369. X  #include "moon.icon"
  370. X***************
  371. X*** 188,193
  372. X  void phasehunt();
  373. X  void drawmoon(), jyear(), jhms();
  374. X  
  375. X  
  376. X  /*  DRAWMOON  --  Construct icon for moon, given phase of moon.  */
  377. X  
  378. X
  379. X--- 220,229 -----
  380. X   * this image to create the displayed image.
  381. X   */
  382. X  
  383. X+ static short moon_img [] = {
  384. X+ #include "moon.icon"
  385. X+ };
  386. X+ mpr_static(moon_mpr, 64, 64, 1, moon_img);
  387. X  
  388. X  extern Pixfont    *font;            /* pointer to regular icon font */
  389. X  extern Pixfont    *sfont;            /* pointer to tiny icon font */
  390. X***************
  391. X*** 189,195
  392. X  void drawmoon(), jyear(), jhms();
  393. X  
  394. X  
  395. X! /*  DRAWMOON  --  Construct icon for moon, given phase of moon.  */
  396. X  
  397. X  static void drawmoon(ph)
  398. X  double ph;
  399. X
  400. X--- 225,239 -----
  401. X  };
  402. X  mpr_static(moon_mpr, 64, 64, 1, moon_img);
  403. X  
  404. X! extern Pixfont    *font;            /* pointer to regular icon font */
  405. X! extern Pixfont    *sfont;            /* pointer to tiny icon font */
  406. X! extern Canvas    mcanvas;            /* handle for the canvas */
  407. X! extern char *monthnames[];
  408. X! static Pixrect    *icon_mpr;        /* actual displayed pixrect */
  409. X! static Pixwin    *cpw;            /* pointer to the canvas' pixwin */
  410. X! static int    charhgt, charwid;    /* default std font height/width */
  411. X! static int info_col;
  412. X! static struct timezone tzp;
  413. X  
  414. X  static char *labels [] = {
  415. X      "Moon phase:",
  416. X***************
  417. X*** 191,198
  418. X  
  419. X  /*  DRAWMOON  --  Construct icon for moon, given phase of moon.  */
  420. X  
  421. X! static void drawmoon(ph)
  422. X! double ph;
  423. X  {
  424. X      int i, j, lx, rx;
  425. X      int lb[4];
  426. X
  427. X--- 235,265 -----
  428. X  static int info_col;
  429. X  static struct timezone tzp;
  430. X  
  431. X! static char *labels [] = {
  432. X!     "Moon phase:",
  433. X!     "Age of moon:",
  434. X!     "Moon's distance:",
  435. X!     "Moon subtends:",
  436. X!     "Last new moon:",
  437. X!     "First quarter:",
  438. X!     "Full moon:",
  439. X!     "Last quarter:",
  440. X!     "Next new moon:"
  441. X! };
  442. X! 
  443. X! /*  Forward functions  */
  444. X! static double        jtime(), phase();
  445. X! static void        phasehunt(), set_mode();
  446. X! static void        drawmoon(), jyear(), jhms();
  447. X! 
  448. X! 
  449. X! /*
  450. X!  * DRAWMOON  --  Construct icon for moon, given phase of moon.
  451. X!  */
  452. X! 
  453. X! static void drawmoon (ph, src_pr, dst_pr)
  454. X! double        ph;
  455. X! Pixrect        *src_pr, *dst_pr;
  456. X  {
  457. X      register int    i, lx, rx;
  458. X      register double    cp, xscale;
  459. X***************
  460. X*** 194,202
  461. X  static void drawmoon(ph)
  462. X  double ph;
  463. X  {
  464. X!     int i, j, lx, rx;
  465. X!     int lb[4];
  466. X!     double cp, xscale;
  467. X  
  468. X      xscale = cos(2 * PI * ph);
  469. X      for (i = 0; i < 24; i++) {
  470. X
  471. X--- 261,272 -----
  472. X  double        ph;
  473. X  Pixrect        *src_pr, *dst_pr;
  474. X  {
  475. X!     register int    i, lx, rx;
  476. X!     register double    cp, xscale;
  477. X! #define RADIUS        27.0
  478. X! #define IRADIUS        27
  479. X! #define OFFSET        28
  480. X! #define CENTER        32
  481. X  
  482. X      /* Clear the destination pixrect to all one-bits (black) */
  483. X      pr_rop (dst_pr, 0, 0, 64, 64, PIX_SET, (Pixrect *)0, 0, 0);
  484. X***************
  485. X*** 198,219
  486. X      int lb[4];
  487. X      double cp, xscale;
  488. X  
  489. X!     xscale = cos(2 * PI * ph);
  490. X!     for (i = 0; i < 24; i++) {
  491. X!        lb[0] = lb[1] = lb[2] = lb[3] = 0xFFFF;
  492. X!        cp = 24.0 * cos(asin(i / 24.0));
  493. X!        if (ph < 0.5) {
  494. X!           rx = 32 + cp;
  495. X!           lx = 32 + xscale * cp;
  496. X!        } else {
  497. X!           lx = 33 - cp;
  498. X!           rx = 33 - xscale * cp;
  499. X!        }
  500. X!        for (j = lx; j <= rx; j++) {
  501. X!           lb[j >> 4] &= (0x8000 >> (j & 0xF)) ^ 0xFFFF;
  502. X!        }
  503. X!        for (j = 0; j < 4; j++)
  504. X!           moon_img[28 + i][j] = moon_img[28 - i][j] = lb[j];
  505. X      }
  506. X  }
  507. X  
  508. X
  509. X--- 268,298 -----
  510. X  #define OFFSET        28
  511. X  #define CENTER        32
  512. X  
  513. X!     /* Clear the destination pixrect to all one-bits (black) */
  514. X!     pr_rop (dst_pr, 0, 0, 64, 64, PIX_SET, (Pixrect *)0, 0, 0);
  515. X! 
  516. X!     xscale = cos (2 * PI * ph);
  517. X!     for (i = 0; i < IRADIUS; i++) {
  518. X!         cp = RADIUS * cos (asin (i / RADIUS));
  519. X!         if (ph < 0.5) {
  520. X!             rx = CENTER + cp;
  521. X!             lx = CENTER + xscale * cp;
  522. X!         } else {
  523. X!             lx = CENTER - cp;
  524. X!             rx = CENTER - xscale * cp;
  525. X!         }
  526. X! 
  527. X!         /*
  528. X!          * We now know the left and right endpoints of the scan line
  529. X!          * for this y coordinate.  We raster-op the corresponding
  530. X!          * scanlines from the source pixrect to the destination
  531. X!          * pixrect, offsetting to properly place it in the pixrect and
  532. X!          * reflecting vertically.
  533. X!          */
  534. X!         pr_rop (dst_pr, lx, OFFSET + i, (rx - lx) + 1, 1, PIX_SRC,
  535. X!             src_pr, lx, OFFSET + i);
  536. X!         pr_rop (dst_pr, lx, OFFSET - i, (rx - lx) + 1, 1, PIX_SRC,
  537. X!             src_pr, lx, OFFSET - i);
  538. X      }
  539. X  }
  540. X  
  541. X***************
  542. X*** 217,222
  543. X      }
  544. X  }
  545. X  
  546. X  /*  MOON_DATA  -- print useful info about the moon */
  547. X  
  548. X  moon_data(seconds)
  549. X
  550. X--- 296,307 -----
  551. X      }
  552. X  }
  553. X  
  554. X+ #define prt(y) pw_text(cpw, info_col, charhgt*(y), PIX_SRC, font, tbuf)
  555. X+ #define prtxy(x,y) pw_text(cpw, charwid*(y+1), charhgt*(x), PIX_SRC,\
  556. X+     font,tbuf)
  557. X+ #define EPL(x) (x), (x) == 1 ? "" : "s"
  558. X+ #define APOS(x) (x + 11)
  559. X+ 
  560. X  /*  MOON_DATA  -- print useful info about the moon */
  561. X  
  562. X  moon_data(seconds)
  563. X***************
  564. X*** 222,238
  565. X  moon_data(seconds)
  566. X  long seconds;
  567. X  {
  568. X!     int lunation, wclosed;
  569. X!     long t;
  570. X!     double jd, p, aom, cphase, cdist, cangdia, csund, csuang, lptime;
  571. X!     double phasar[5];
  572. X!     struct pr_prpos tloc;
  573. X!     char amsg[12], tbuf[80];
  574. X!     static double faketime = 0.0;
  575. X!     static short moonilast[64][4] = {0};
  576. X!     int yy, mm, dd, hh, mmm, ss;
  577. X!     Pixfont *pfont;
  578. X!     struct tm *gm, *ltm, *localtime();
  579. X      struct timeval tvp;
  580. X      struct timezone tzp;
  581. X      long clock;
  582. X
  583. X--- 307,320 -----
  584. X  moon_data(seconds)
  585. X  long seconds;
  586. X  {
  587. X!     int        lunation, wclosed;
  588. X!     int        i, yy, mm, dd, hh, mmm, ss;
  589. X!     int        aom_d, aom_h, aom_m;
  590. X!     long        t;
  591. X!     double        jd, p, aom, cphase, cdist, cangdia, csund, csuang;
  592. X!     double        phasar [5];
  593. X!     char        tbuf[80];
  594. X!     struct tm    *gm, *ltm, *localtime();
  595. X      struct timeval tvp;
  596. X      struct pr_prpos    tloc;
  597. X      struct pr_size    txt_size;
  598. X***************
  599. X*** 234,240
  600. X      Pixfont *pfont;
  601. X      struct tm *gm, *ltm, *localtime();
  602. X      struct timeval tvp;
  603. X!     struct timezone tzp;
  604. X      long clock;
  605. X      char *atp, *asctime();
  606. X  
  607. X
  608. X--- 316,323 -----
  609. X      char        tbuf[80];
  610. X      struct tm    *gm, *ltm, *localtime();
  611. X      struct timeval tvp;
  612. X!     struct pr_prpos    tloc;
  613. X!     struct pr_size    txt_size;
  614. X      long clock;
  615. X      char *atp, *asctime();
  616. X  
  617. X***************
  618. X*** 238,245
  619. X      long clock;
  620. X      char *atp, *asctime();
  621. X  
  622. X! 
  623. X!     pfont = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.r.7");
  624. X      cpw = canvas_pixwin(mcanvas);
  625. X      charwid = font->pf_defaultsize.x;
  626. X      charhgt = font->pf_defaultsize.y;
  627. X
  628. X--- 321,328 -----
  629. X      long clock;
  630. X      char *atp, *asctime();
  631. X  
  632. X!     icon_mpr = mem_create (64, 64, 1);
  633. X!     pr_rop (icon_mpr, 0, 0, 64, 64, PIX_SRC, &moon_mpr, 0, 0);
  634. X      cpw = canvas_pixwin(mcanvas);
  635. X      charwid = font->pf_defaultsize.x;
  636. X      charhgt = font->pf_defaultsize.y;
  637. X***************
  638. X*** 243,249
  639. X      cpw = canvas_pixwin(mcanvas);
  640. X      charwid = font->pf_defaultsize.x;
  641. X      charhgt = font->pf_defaultsize.y;
  642. X!     jd = jtime((gm = gmtime(&seconds)));
  643. X      gettimeofday(&tvp, &tzp); /* for timezone info */
  644. X      p = phase(jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
  645. X      drawmoon(p);
  646. X
  647. X--- 326,333 -----
  648. X      cpw = canvas_pixwin(mcanvas);
  649. X      charwid = font->pf_defaultsize.x;
  650. X      charhgt = font->pf_defaultsize.y;
  651. X!     info_col = charwid * 20;
  652. X!     jd = jtime ((gm = gmtime (&seconds)));
  653. X      gettimeofday(&tvp, &tzp); /* for timezone info */
  654. X      p = phase (jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
  655. X      aom_d = (int) aom;
  656. X***************
  657. X*** 245,258
  658. X      charhgt = font->pf_defaultsize.y;
  659. X      jd = jtime((gm = gmtime(&seconds)));
  660. X      gettimeofday(&tvp, &tzp); /* for timezone info */
  661. X!     p = phase(jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
  662. X!     drawmoon(p);
  663. X!         sprintf(amsg, " %dd %dh  ",
  664. X!        (int) aom, ((int) (24 * (aom - floor(aom)))));
  665. X!     tloc.pr = (Pixrect *) icon_get(&moon_icon, ICON_IMAGE);
  666. X!     tloc.pos.x = 2;
  667. X!     tloc.pos.y = 62;
  668. X!     pf_text(tloc, PIX_NOT(PIX_SRC), pfont, amsg);
  669. X  
  670. X      /* Only update icon if it changed (this eliminates gratuitous
  671. X         flashing of the icon on-screen). */
  672. X
  673. X--- 329,338 -----
  674. X      info_col = charwid * 20;
  675. X      jd = jtime ((gm = gmtime (&seconds)));
  676. X      gettimeofday(&tvp, &tzp); /* for timezone info */
  677. X!     p = phase (jd, &cphase, &aom, &cdist, &cangdia, &csund, &csuang);
  678. X!     aom_d = (int) aom;
  679. X!     aom_h = (int) (24 * (aom - floor(aom)));
  680. X!     aom_m = (int) (1440 * (aom - floor(aom))) % 60;
  681. X  
  682. X      drawmoon(p, &moon_mpr, icon_mpr);
  683. X  
  684. X***************
  685. X*** 254,261
  686. X      tloc.pos.y = 62;
  687. X      pf_text(tloc, PIX_NOT(PIX_SRC), pfont, amsg);
  688. X  
  689. X!     /* Only update icon if it changed (this eliminates gratuitous
  690. X!        flashing of the icon on-screen). */
  691. X  
  692. X      if (bcmp(moonilast, moon_img, sizeof moon_img) != 0)
  693. X         bcopy(moon_img, moonilast, sizeof moon_img);
  694. X
  695. X--- 334,340 -----
  696. X      aom_h = (int) (24 * (aom - floor(aom)));
  697. X      aom_m = (int) (1440 * (aom - floor(aom))) % 60;
  698. X  
  699. X!     drawmoon(p, &moon_mpr, icon_mpr);
  700. X  
  701. X      if (aom_d == 0) {
  702. X          (void)sprintf(tbuf, "%dh %dm", aom_h, aom_m);
  703. X***************
  704. X*** 257,264
  705. X      /* Only update icon if it changed (this eliminates gratuitous
  706. X         flashing of the icon on-screen). */
  707. X  
  708. X!     if (bcmp(moonilast, moon_img, sizeof moon_img) != 0)
  709. X!        bcopy(moon_img, moonilast, sizeof moon_img);
  710. X  
  711. X      /* Update textual information for open window */
  712. X  
  713. X
  714. X--- 336,351 -----
  715. X  
  716. X      drawmoon(p, &moon_mpr, icon_mpr);
  717. X  
  718. X!     if (aom_d == 0) {
  719. X!         (void)sprintf(tbuf, "%dh %dm", aom_h, aom_m);
  720. X!     } else {
  721. X!         (void)sprintf(tbuf, "%dd %dh", aom_d, aom_h);
  722. X!     }
  723. X!     txt_size = pf_textwidth (strlen (tbuf), sfont, tbuf);
  724. X!     tloc.pos.x = (64 - txt_size.x) / 2;
  725. X!     tloc.pos.y = 63;
  726. X!     tloc.pr = icon_mpr;
  727. X!     pf_text (tloc, PIX_NOT(PIX_SRC), sfont, tbuf);
  728. X  
  729. X      /* Update textual information for open window */
  730. X  
  731. X***************
  732. X*** 262,269
  733. X  
  734. X      /* Update textual information for open window */
  735. X  
  736. X! #define prt(x) pw_text(cpw, charwid, charhgt * (x), PIX_SRC, font, tbuf)
  737. X! #define prtxy(x,y) pw_text(cpw,charwid*(y+1),charhgt*(x),PIX_SRC,font,tbuf)
  738. X  
  739. X          sprintf(tbuf, "Moon phase:      %d%%   [0%% = New, 100%% = Full]  ",
  740. X         (int) (cphase * 100));
  741. X
  742. X--- 349,356 -----
  743. X  
  744. X      /* Update textual information for open window */
  745. X  
  746. X!     /* start batching updates to the pixwin */
  747. X!     pw_batch_on (cpw);
  748. X  
  749. X      paint_labels();
  750. X      /* moon phase */
  751. X***************
  752. X*** 265,272
  753. X  #define prt(x) pw_text(cpw, charwid, charhgt * (x), PIX_SRC, font, tbuf)
  754. X  #define prtxy(x,y) pw_text(cpw,charwid*(y+1),charhgt*(x),PIX_SRC,font,tbuf)
  755. X  
  756. X!         sprintf(tbuf, "Moon phase:      %d%%   [0%% = New, 100%% = Full]  ",
  757. X!        (int) (cphase * 100));
  758. X      prt(1);
  759. X  
  760. X      /* Information about the Moon */
  761. X
  762. X--- 352,361 -----
  763. X      /* start batching updates to the pixwin */
  764. X      pw_batch_on (cpw);
  765. X  
  766. X!     paint_labels();
  767. X!     /* moon phase */
  768. X!     (void)sprintf (tbuf, "%d%%   [0%% = New, 100%% = Full]  ",
  769. X!         (int) (cphase * 100));
  770. X      prt(1);
  771. X  
  772. X      /* Information about the Moon */
  773. X***************
  774. X*** 271,281
  775. X  
  776. X      /* Information about the Moon */
  777. X  
  778. X! #define EPL(x) (x), (x) == 1 ? "" : "s"
  779. X!     sprintf(tbuf,
  780. X!            "Age of moon:     %d day%s, %d hour%s, %d minute%s.       ",
  781. X!        EPL((int) aom), EPL(((int) (24 * (aom - floor(aom))))),
  782. X!        EPL(((int) (1440 * (aom - floor(aom)))) % 60));
  783. X      prt(2);
  784. X      sprintf(tbuf,
  785. X             "Moon's distance: %ld kilometres, %.1f Earth radii.  ",
  786. X
  787. X--- 360,368 -----
  788. X  
  789. X      /* Information about the Moon */
  790. X  
  791. X!     /* age of moon */
  792. X!     (void)sprintf (tbuf, "%d day%s, %d hour%s, %d minute%s.       ",
  793. X!         EPL(aom_d), EPL(aom_h), EPL(aom_m));
  794. X      prt(2);
  795. X  
  796. X      /* moon distance */
  797. X***************
  798. X*** 277,285
  799. X         EPL((int) aom), EPL(((int) (24 * (aom - floor(aom))))),
  800. X         EPL(((int) (1440 * (aom - floor(aom)))) % 60));
  801. X      prt(2);
  802. X!     sprintf(tbuf,
  803. X!            "Moon's distance: %ld kilometres, %.1f Earth radii.  ",
  804. X!        (long) cdist, cdist / earthrad);
  805. X      prt(3);
  806. X      sprintf(tbuf,
  807. X             "Moon subtends:   %.4f degrees.       ", cangdia);
  808. X
  809. X--- 364,373 -----
  810. X      (void)sprintf (tbuf, "%d day%s, %d hour%s, %d minute%s.       ",
  811. X          EPL(aom_d), EPL(aom_h), EPL(aom_m));
  812. X      prt(2);
  813. X! 
  814. X!     /* moon distance */
  815. X!     (void)sprintf (tbuf, "%ld kilometres, %.1f Earth radii.  ",
  816. X!         (long) cdist, cdist / earthrad);
  817. X      prt(3);
  818. X  
  819. X      /* moon subtends */
  820. X***************
  821. X*** 281,288
  822. X             "Moon's distance: %ld kilometres, %.1f Earth radii.  ",
  823. X         (long) cdist, cdist / earthrad);
  824. X      prt(3);
  825. X!     sprintf(tbuf,
  826. X!            "Moon subtends:   %.4f degrees.       ", cangdia);
  827. X      prt(4);
  828. X      /* Draw the moon icon in the text window */
  829. X      pw_rop(cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC,
  830. X
  831. X--- 369,377 -----
  832. X      (void)sprintf (tbuf, "%ld kilometres, %.1f Earth radii.  ",
  833. X          (long) cdist, cdist / earthrad);
  834. X      prt(3);
  835. X! 
  836. X!     /* moon subtends */
  837. X!     (void)sprintf (tbuf, "%.4f degrees.       ", cangdia);
  838. X      prt(4);
  839. X  
  840. X      /* paint the moon's image in the upper right of the canvas */
  841. X***************
  842. X*** 284,292
  843. X      sprintf(tbuf,
  844. X             "Moon subtends:   %.4f degrees.       ", cangdia);
  845. X      prt(4);
  846. X-     /* Draw the moon icon in the text window */
  847. X-     pw_rop(cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC,
  848. X-        &icon_mpr, 0, 0);
  849. X  
  850. X  
  851. X      /* Calculate times of phases of this lunation. */
  852. X
  853. X--- 373,378 -----
  854. X      /* moon subtends */
  855. X      (void)sprintf (tbuf, "%.4f degrees.       ", cangdia);
  856. X      prt(4);
  857. X  
  858. X      /* paint the moon's image in the upper right of the canvas */
  859. X      pw_rop (cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC, icon_mpr, 0, 0);
  860. X***************
  861. X*** 288,293
  862. X      pw_rop(cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC,
  863. X         &icon_mpr, 0, 0);
  864. X  
  865. X  
  866. X      /* Calculate times of phases of this lunation. */
  867. X  
  868. X
  869. X--- 374,381 -----
  870. X      (void)sprintf (tbuf, "%.4f degrees.       ", cangdia);
  871. X      prt(4);
  872. X  
  873. X+     /* paint the moon's image in the upper right of the canvas */
  874. X+     pw_rop (cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC, icon_mpr, 0, 0);
  875. X  
  876. X      /*
  877. X       * Calculate times of phases of this lunation.
  878. X***************
  879. X*** 289,295
  880. X         &icon_mpr, 0, 0);
  881. X  
  882. X  
  883. X!     /* Calculate times of phases of this lunation. */
  884. X  
  885. X  #define APOS(x) (x + 11)
  886. X      phasehunt(jd, phasar);
  887. X
  888. X--- 377,386 -----
  889. X      /* paint the moon's image in the upper right of the canvas */
  890. X      pw_rop (cpw, 60 * charwid, charhgt, 64, 64, PIX_SRC, icon_mpr, 0, 0);
  891. X  
  892. X!     /*
  893. X!      * Calculate times of phases of this lunation.
  894. X!      */
  895. X!     phasehunt(jd + 0.5, phasar);
  896. X  
  897. X      for (i = 0; i < 5; i++) {
  898. X          fmt_phase_time (phasar[i], tbuf);
  899. X***************
  900. X*** 291,310
  901. X  
  902. X      /* Calculate times of phases of this lunation. */
  903. X  
  904. X! #define APOS(x) (x + 11)
  905. X!     phasehunt(jd, phasar);
  906. X!     lptime = phasar[0];
  907. X!     lunation = floor(((lptime + 7) - lunatbase) / synmonth) + 1;
  908. X!     /* convert to seconds local time, so we can use localtime()
  909. X!        to handle dst calculations */
  910. X!     clock = (long)((lptime - J1970) * 24. * 3600.);
  911. X!     ltm = localtime(&clock);
  912. X!     sprintf(tbuf,
  913. X!            "Last new moon:   %02d:%02d %s %2d %s %d             ",
  914. X!        ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  915. X!     prt(APOS(0));
  916. X!         sprintf(tbuf, "Lunation %d    ", lunation);
  917. X!     prtxy(APOS(0), 52);
  918. X  
  919. X      lptime = phasar[1];
  920. X      /* convert to seconds local time, so we can use localtime()
  921. X
  922. X--- 382,391 -----
  923. X       */
  924. X      phasehunt(jd + 0.5, phasar);
  925. X  
  926. X!     for (i = 0; i < 5; i++) {
  927. X!         fmt_phase_time (phasar[i], tbuf);
  928. X!         prt(APOS(i));
  929. X!     }
  930. X  
  931. X      lunation = floor(((phasar[0] + 7) - lunatbase) / synmonth) + 1;
  932. X      (void)sprintf(tbuf, "Lunation %d ", lunation);
  933. X***************
  934. X*** 306,320
  935. X          sprintf(tbuf, "Lunation %d    ", lunation);
  936. X      prtxy(APOS(0), 52);
  937. X  
  938. X!     lptime = phasar[1];
  939. X!     /* convert to seconds local time, so we can use localtime()
  940. X!        to handle dst calculations */
  941. X!     clock = (long)((lptime - J1970) * 24. * 3600.);
  942. X!     ltm = localtime(&clock);
  943. X!     sprintf(tbuf,
  944. X!            "First quarter:   %02d:%02d %s %2d %s %d              ",
  945. X!        ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  946. X!     prt(APOS(1));
  947. X  
  948. X      lptime = phasar[2];
  949. X      /* convert to seconds local time, so we can use localtime()
  950. X
  951. X--- 387,397 -----
  952. X          prt(APOS(i));
  953. X      }
  954. X  
  955. X!     lunation = floor(((phasar[0] + 7) - lunatbase) / synmonth) + 1;
  956. X!     (void)sprintf(tbuf, "Lunation %d ", lunation);
  957. X!     prtxy(APOS(0), 49);                  
  958. X!     (void)sprintf(tbuf, "Lunation %d ", lunation + 1);
  959. X!     prtxy(APOS(4), 49);
  960. X  
  961. X      /* flush the pixwin updates to the screen */
  962. X      pw_batch_off (cpw);
  963. X***************
  964. X*** 316,330
  965. X         ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  966. X      prt(APOS(1));
  967. X  
  968. X!     lptime = phasar[2];
  969. X!     /* convert to seconds local time, so we can use localtime()
  970. X!        to handle dst calculations */
  971. X!     clock = (long)((lptime - J1970) * 24. * 3600.);
  972. X!     ltm = localtime(&clock);
  973. X!     sprintf(tbuf,
  974. X!            "Full moon:       %02d:%02d %s %2d %s %d              ",
  975. X!        ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  976. X!     prt(APOS(2));
  977. X  
  978. X      lptime = phasar[3];
  979. X      /* convert to seconds local time, so we can use localtime()
  980. X
  981. X--- 393,400 -----
  982. X      (void)sprintf(tbuf, "Lunation %d ", lunation + 1);
  983. X      prtxy(APOS(4), 49);
  984. X  
  985. X!     /* flush the pixwin updates to the screen */
  986. X!     pw_batch_off (cpw);
  987. X  
  988. X      return;
  989. X  }
  990. X***************
  991. X*** 326,340
  992. X         ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  993. X      prt(APOS(2));
  994. X  
  995. X!     lptime = phasar[3];
  996. X!     /* convert to seconds local time, so we can use localtime()
  997. X!        to handle dst calculations */
  998. X!     clock = (long)((lptime - J1970) * 24. * 3600.);
  999. X!     ltm = localtime(&clock);
  1000. X!     sprintf(tbuf,
  1001. X!            "Last quarter:    %02d:%02d %s %2d %s %d              ",
  1002. X!        ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  1003. X!     prt(APOS(3));
  1004. X  
  1005. X      lptime = phasar[4];
  1006. X      /* convert to seconds local time, so we can use localtime()
  1007. X
  1008. X--- 396,404 -----
  1009. X      /* flush the pixwin updates to the screen */
  1010. X      pw_batch_off (cpw);
  1011. X  
  1012. X!     return;
  1013. X! }
  1014. X! #undef APOS
  1015. X  
  1016. X  
  1017. X  /*
  1018. X***************
  1019. X*** 336,342
  1020. X         ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  1021. X      prt(APOS(3));
  1022. X  
  1023. X!     lptime = phasar[4];
  1024. X      /* convert to seconds local time, so we can use localtime()
  1025. X         to handle dst calculations */
  1026. X      clock = (long)rint((lptime - J1970) * 24. * 3600.);
  1027. X
  1028. X--- 400,418 -----
  1029. X  }
  1030. X  #undef APOS
  1031. X  
  1032. X! 
  1033. X! /*
  1034. X!  * FMT_PHASE_TIME -- Format the provided julian date into the provided buffer
  1035. X!  *        in local time format for screen display
  1036. X!  */
  1037. X! 
  1038. X! fmt_phase_time (utime, buf)
  1039. X!     double    utime;
  1040. X!     char    *buf;
  1041. X! {
  1042. X!     long    clock;
  1043. X!     struct tm    *ltm, *localtime();
  1044. X! 
  1045. X      /* convert to seconds local time, so we can use localtime()
  1046. X         to handle dst calculations */
  1047. X      clock = (long)((utime - J1970) * 24. * 3600.);
  1048. X***************
  1049. X*** 339,345
  1050. X      lptime = phasar[4];
  1051. X      /* convert to seconds local time, so we can use localtime()
  1052. X         to handle dst calculations */
  1053. X!     clock = (long)rint((lptime - J1970) * 24. * 3600.);
  1054. X      ltm = localtime(&clock);
  1055. X      sprintf(tbuf,
  1056. X             "Next new moon:   %02d:%02d %s %2d %s %d              ",
  1057. X
  1058. X--- 415,421 -----
  1059. X  
  1060. X      /* convert to seconds local time, so we can use localtime()
  1061. X         to handle dst calculations */
  1062. X!     clock = (long)((utime - J1970) * 24. * 3600.);
  1063. X      ltm = localtime(&clock);
  1064. X      (void)sprintf (buf, " %02d:%02d %s %2d %s %d             ",
  1065. X      ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  1066. X***************
  1067. X*** 341,353
  1068. X         to handle dst calculations */
  1069. X      clock = (long)rint((lptime - J1970) * 24. * 3600.);
  1070. X      ltm = localtime(&clock);
  1071. X!     sprintf(tbuf,
  1072. X!            "Next new moon:   %02d:%02d %s %2d %s %d              ",
  1073. X!        ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  1074. X!     prt(APOS(4));
  1075. X!         sprintf(tbuf, "Lunation %d    ", lunation + 1);
  1076. X!     prtxy(APOS(4), 52);
  1077. X! #undef APOS
  1078. X  }
  1079. X  
  1080. X  /*  JDATE  --  Convert internal GMT date and time to Julian day
  1081. X
  1082. X--- 417,424 -----
  1083. X         to handle dst calculations */
  1084. X      clock = (long)((utime - J1970) * 24. * 3600.);
  1085. X      ltm = localtime(&clock);
  1086. X!     (void)sprintf (buf, " %02d:%02d %s %2d %s %d             ",
  1087. X!     ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  1088. X  }
  1089. X  
  1090. X  
  1091. X***************
  1092. X*** 350,357
  1093. X  #undef APOS
  1094. X  }
  1095. X  
  1096. X- /*  JDATE  --  Convert internal GMT date and time to Julian day
  1097. X-            and fraction.  */
  1098. X  
  1099. X  static long jdate(t)
  1100. X  struct tm *t;
  1101. X
  1102. X--- 421,426 -----
  1103. X      ltm->tm_hour, ltm->tm_min, timezone(tzp.tz_minuteswest, ltm->tm_isdst), ltm->tm_mday, monthnames[ltm->tm_mon], ltm->tm_year+1900);
  1104. X  }
  1105. X  
  1106. X  
  1107. X  /*
  1108. X   * PAINT_LABELS -- Draw the labels into the canvas (open) window and right
  1109. X***************
  1110. X*** 353,360
  1111. X  /*  JDATE  --  Convert internal GMT date and time to Julian day
  1112. X             and fraction.  */
  1113. X  
  1114. X! static long jdate(t)
  1115. X! struct tm *t;
  1116. X  {
  1117. X      long c, m, y;
  1118. X  
  1119. X
  1120. X--- 422,435 -----
  1121. X  }
  1122. X  
  1123. X  
  1124. X! /*
  1125. X!  * PAINT_LABELS -- Draw the labels into the canvas (open) window and right
  1126. X!  *        justify them.  Done once at startup.  We paint the labels
  1127. X!  *        separately to minimize the amount of screen real-estate
  1128. X!  *        being modified on each update.
  1129. X!  */
  1130. X! 
  1131. X! paint_labels ()
  1132. X  {
  1133. X      int    i;
  1134. X  
  1135. X***************
  1136. X*** 356,362
  1137. X  static long jdate(t)
  1138. X  struct tm *t;
  1139. X  {
  1140. X!     long c, m, y;
  1141. X  
  1142. X      y = t->tm_year + 1900;
  1143. X      m = t->tm_mon + 1;
  1144. X
  1145. X--- 431,437 -----
  1146. X  
  1147. X  paint_labels ()
  1148. X  {
  1149. X!     int    i;
  1150. X  
  1151. X      for (i = 0; i < 4; i++) {
  1152. X          pw_text (cpw, charwid * (17 - strlen (labels [i])),
  1153. X***************
  1154. X*** 358,363
  1155. X  {
  1156. X      long c, m, y;
  1157. X  
  1158. X      y = t->tm_year + 1900;
  1159. X      m = t->tm_mon + 1;
  1160. X      if (m > 2)
  1161. X
  1162. X--- 433,463 -----
  1163. X  {
  1164. X      int    i;
  1165. X  
  1166. X+     for (i = 0; i < 4; i++) {
  1167. X+         pw_text (cpw, charwid * (17 - strlen (labels [i])),
  1168. X+             charhgt * (i + 1), PIX_SRC,
  1169. X+             font, labels[i]);
  1170. X+     }
  1171. X+     for (i = 4; i < 9; i++) {
  1172. X+         pw_text (cpw, charwid * (17 - strlen (labels [i])),
  1173. X+             charhgt * (i + 7), PIX_SRC,
  1174. X+             font, labels[i]);
  1175. X+     }
  1176. X+ }
  1177. X+ 
  1178. X+ 
  1179. X+ /*
  1180. X+  * JDATE  --  Convert internal GMT date and time to Julian day
  1181. X+  *           and fraction.
  1182. X+  */
  1183. X+ 
  1184. X+ static
  1185. X+ long
  1186. X+ jdate (t)
  1187. X+     struct tm    *t;
  1188. X+ {
  1189. X+     long        c, m, y;
  1190. X+ 
  1191. X      y = t->tm_year + 1900;
  1192. X      m = t->tm_mon + 1;
  1193. X      if (m > 2) {
  1194. X***************
  1195. X*** 360,370
  1196. X  
  1197. X      y = t->tm_year + 1900;
  1198. X      m = t->tm_mon + 1;
  1199. X!     if (m > 2)
  1200. X!        m = m - 3;
  1201. X!     else {
  1202. X!        m = m + 9;
  1203. X!        y--;
  1204. X      }
  1205. X      c = y / 100L;           /* Compute century */
  1206. X      y -= 100L * c;
  1207. X
  1208. X--- 460,470 -----
  1209. X  
  1210. X      y = t->tm_year + 1900;
  1211. X      m = t->tm_mon + 1;
  1212. X!     if (m > 2) {
  1213. X!         m = m - 3;
  1214. X!     } else {
  1215. X!         m = m + 9;
  1216. X!         y--;
  1217. X      }
  1218. X      c = y / 100L;           /* Compute century */
  1219. X      y -= 100L * c;
  1220. X***************
  1221. X*** 368,375
  1222. X      }
  1223. X      c = y / 100L;           /* Compute century */
  1224. X      y -= 100L * c;
  1225. X!     return t->tm_mday + (c * 146097L) / 4 + (y * 1461L) / 4 +
  1226. X!         (m * 153L + 2) / 5 + 1721119L;
  1227. X  }
  1228. X  
  1229. X  /* JTIME --    Convert internal GMT date and time to astronomical Julian
  1230. X
  1231. X--- 468,475 -----
  1232. X      }
  1233. X      c = y / 100L;           /* Compute century */
  1234. X      y -= 100L * c;
  1235. X!     return (t->tm_mday + (c * 146097L) / 4 + (y * 1461L) / 4 +
  1236. X!         (m * 153L + 2) / 5 + 1721119L);
  1237. X  }
  1238. X  
  1239. X  
  1240. X***************
  1241. X*** 372,380
  1242. X          (m * 153L + 2) / 5 + 1721119L;
  1243. X  }
  1244. X  
  1245. X- /* JTIME --    Convert internal GMT date and time to astronomical Julian
  1246. X-            time (i.e. Julian date plus day fraction, expressed as
  1247. X-            a double).  */
  1248. X  
  1249. X  static double jtime(t)
  1250. X  struct tm *t;
  1251. X
  1252. X--- 472,477 -----
  1253. X          (m * 153L + 2) / 5 + 1721119L);
  1254. X  }
  1255. X  
  1256. X  
  1257. X  /*
  1258. X   * JTIME --    Convert internal GMT date and time to astronomical Julian
  1259. X***************
  1260. X*** 376,383
  1261. X             time (i.e. Julian date plus day fraction, expressed as
  1262. X             a double).  */
  1263. X  
  1264. X! static double jtime(t)
  1265. X! struct tm *t;
  1266. X  {
  1267. X      return (jdate(t) - 0.5) + 
  1268. X         (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
  1269. X
  1270. X--- 473,488 -----
  1271. X  }
  1272. X  
  1273. X  
  1274. X! /*
  1275. X!  * JTIME --    Convert internal GMT date and time to astronomical Julian
  1276. X!  *           time (i.e. Julian date plus day fraction, expressed as
  1277. X!  *           a double).
  1278. X!  */
  1279. X! 
  1280. X! static
  1281. X! double
  1282. X! jtime (t)
  1283. X!     struct tm *t;
  1284. X  {
  1285. X      return (jdate (t) - 0.5) + 
  1286. X         (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
  1287. X***************
  1288. X*** 379,385
  1289. X  static double jtime(t)
  1290. X  struct tm *t;
  1291. X  {
  1292. X!     return (jdate(t) - 0.5) + 
  1293. X         (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
  1294. X  }
  1295. X  
  1296. X
  1297. X--- 484,490 -----
  1298. X  jtime (t)
  1299. X      struct tm *t;
  1300. X  {
  1301. X!     return (jdate (t) - 0.5) + 
  1302. X         (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
  1303. X  }
  1304. X  
  1305. X***************
  1306. X*** 383,390
  1307. X         (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
  1308. X  }
  1309. X  
  1310. X- /*  JYEAR  --  Convert Julian date to year, month, day, which are
  1311. X-            returned via integer pointers to integers.  */
  1312. X  
  1313. X  static void jyear(td, yy, mm, dd)
  1314. X  double td;
  1315. X
  1316. X--- 488,493 -----
  1317. X         (t->tm_sec + 60 * (t->tm_min + 60 * t->tm_hour)) / 86400.0;
  1318. X  }
  1319. X  
  1320. X  
  1321. X  /*
  1322. X   * JYEAR  --  Convert Julian date to year, month, day, which are
  1323. X***************
  1324. X*** 386,394
  1325. X  /*  JYEAR  --  Convert Julian date to year, month, day, which are
  1326. X             returned via integer pointers to integers.  */
  1327. X  
  1328. X! static void jyear(td, yy, mm, dd)
  1329. X! double td;
  1330. X! int *yy, *mm, *dd;
  1331. X  {
  1332. X      double j, d, y, m;
  1333. X  
  1334. X
  1335. X--- 489,504 -----
  1336. X  }
  1337. X  
  1338. X  
  1339. X! /*
  1340. X!  * JYEAR  --  Convert Julian date to year, month, day, which are
  1341. X!  *           returned via integer pointers to integers.  
  1342. X!  */
  1343. X! 
  1344. X! static
  1345. X! void
  1346. X! jyear (td, yy, mm, dd)
  1347. X!     double    td;
  1348. X!     int    *yy, *mm, *dd;
  1349. X  {
  1350. X      double j, d, y, m;
  1351. X  
  1352. X***************
  1353. X*** 392,398
  1354. X  {
  1355. X      double j, d, y, m;
  1356. X  
  1357. X!     td += 0.5;           /* Astronomical to civil */
  1358. X      j = floor(td);
  1359. X      j = j - 1721119.0;
  1360. X      y = floor(((4 * j) - 1) / 146097.0);
  1361. X
  1362. X--- 502,508 -----
  1363. X  {
  1364. X      double j, d, y, m;
  1365. X  
  1366. X!     td += 0.5;                /* Astronomical to civil */
  1367. X      j = floor(td);
  1368. X      j = j - 1721119.0;
  1369. X      y = floor(((4 * j) - 1) / 146097.0);
  1370. X***************
  1371. X*** 406,412
  1372. X      d = floor((d + 5.0) / 5.0);
  1373. X      y = (100.0 * y) + j;
  1374. X      if (m < 10.0)
  1375. X!        m = m + 3;
  1376. X      else {
  1377. X         m = m - 9;
  1378. X         y = y + 1;
  1379. X
  1380. X--- 516,522 -----
  1381. X      d = floor((d + 5.0) / 5.0);
  1382. X      y = (100.0 * y) + j;
  1383. X      if (m < 10.0)
  1384. X!         m = m + 3;
  1385. X      else {
  1386. X          m = m - 9;
  1387. X          y = y + 1;
  1388. X***************
  1389. X*** 408,415
  1390. X      if (m < 10.0)
  1391. X         m = m + 3;
  1392. X      else {
  1393. X!        m = m - 9;
  1394. X!        y = y + 1;
  1395. X      }
  1396. X      *yy = y;
  1397. X      *mm = m;
  1398. X
  1399. X--- 518,525 -----
  1400. X      if (m < 10.0)
  1401. X          m = m + 3;
  1402. X      else {
  1403. X!         m = m - 9;
  1404. X!         y = y + 1;
  1405. X      }
  1406. X      *yy = y;
  1407. X      *mm = m;
  1408. X***************
  1409. X*** 416,422
  1410. X      *dd = d;
  1411. X  }
  1412. X  
  1413. X- /*  JHMS  --  Convert Julian time to hour, minutes, and seconds.  */
  1414. X  
  1415. X  static void jhms(j, h, m, s)
  1416. X  double j;
  1417. X
  1418. X--- 526,531 -----
  1419. X      *dd = d;
  1420. X  }
  1421. X  
  1422. X  
  1423. X  /*
  1424. X   * JHMS  --  Convert Julian time to hour, minutes, and seconds.
  1425. X***************
  1426. X*** 418,426
  1427. X  
  1428. X  /*  JHMS  --  Convert Julian time to hour, minutes, and seconds.  */
  1429. X  
  1430. X! static void jhms(j, h, m, s)
  1431. X! double j;
  1432. X! int *h, *m, *s;
  1433. X  {
  1434. X      long ij;
  1435. X  
  1436. X
  1437. X--- 527,541 -----
  1438. X  }
  1439. X  
  1440. X  
  1441. X! /*
  1442. X!  * JHMS  --  Convert Julian time to hour, minutes, and seconds.
  1443. X!  */
  1444. X! 
  1445. X! static
  1446. X! void
  1447. X! jhms(j, h, m, s)
  1448. X!     double j;
  1449. X!     int *h, *m, *s;
  1450. X  {
  1451. X      long ij;
  1452. X  
  1453. X***************
  1454. X*** 424,430
  1455. X  {
  1456. X      long ij;
  1457. X  
  1458. X!     j += 0.5;           /* Astronomical to civil */
  1459. X      ij = (j - floor(j)) * 86400.0;
  1460. X      *h = ij / 3600L;
  1461. X      *m = (ij / 60L) % 60L;
  1462. X
  1463. X--- 539,545 -----
  1464. X  {
  1465. X      long ij;
  1466. X  
  1467. X!     j += 0.5;                /* Astronomical to civil */
  1468. X      ij = (j - floor(j)) * 86400.0;
  1469. X      *h = ij / 3600L;
  1470. X      *m = (ij / 60L) % 60L;
  1471. X***************
  1472. X*** 431,447
  1473. X      *s = ij % 60L;
  1474. X  }
  1475. X  
  1476. X- /*  MEANPHASE  --  Calculates mean phase of the Moon for a given
  1477. X-            base date and desired phase:
  1478. X-                0.0   New Moon
  1479. X-                0.25  First quarter
  1480. X-                0.5   Full moon
  1481. X-                0.75  Last quarter
  1482. X-             Beware!!!  This routine returns meaningless
  1483. X-                     results for any other phase arguments.  Don't
  1484. X-             attempt to generalise it without understanding
  1485. X-             that the motion of the moon is far more complicated
  1486. X-             that this calculation reveals. */
  1487. X  
  1488. X  static double meanphase(sdate, phase, usek)
  1489. X  double sdate, phase;
  1490. X
  1491. X--- 546,551 -----
  1492. X      *s = ij % 60L;
  1493. X  }
  1494. X  
  1495. X  
  1496. X  /*
  1497. X   * MEANPHASE  --  Calculates mean phase of the Moon for a given
  1498. X***************
  1499. X*** 443,451
  1500. X              that the motion of the moon is far more complicated
  1501. X              that this calculation reveals. */
  1502. X  
  1503. X! static double meanphase(sdate, phase, usek)
  1504. X! double sdate, phase;
  1505. X! double *usek;
  1506. X  {
  1507. X      int yy, mm, dd;
  1508. X      double k, t, t2, t3, nt1;
  1509. X
  1510. X--- 547,567 -----
  1511. X  }
  1512. X  
  1513. X  
  1514. X! /*
  1515. X!  * MEANPHASE  --  Calculates mean phase of the Moon for a given
  1516. X!  *        base date.  This argument K to this function is
  1517. X!  *        the precomputed synodic month index, given by:
  1518. X!  *
  1519. X!  *            K = (year - 1900) * 12.3685
  1520. X!  *
  1521. X!  *        where year is expressed as a year and fractional
  1522. X!  *        year.
  1523. X!  */
  1524. X! 
  1525. X! static
  1526. X! double
  1527. X! meanphase (sdate, k)
  1528. X!     double    sdate, k;
  1529. X  {
  1530. X      double    t, t2, t3, nt1;
  1531. X  
  1532. X***************
  1533. X*** 447,454
  1534. X  double sdate, phase;
  1535. X  double *usek;
  1536. X  {
  1537. X!     int yy, mm, dd;
  1538. X!     double k, t, t2, t3, nt1;
  1539. X  
  1540. X      jyear(sdate, &yy, &mm, &dd);
  1541. X  
  1542. X
  1543. X--- 563,569 -----
  1544. X  meanphase (sdate, k)
  1545. X      double    sdate, k;
  1546. X  {
  1547. X!     double    t, t2, t3, nt1;
  1548. X  
  1549. X      /* Time in Julian centuries from 1900 January 0.5 */
  1550. X      t = (sdate - 2415020.0) / 36525;
  1551. X***************
  1552. X*** 450,459
  1553. X      int yy, mm, dd;
  1554. X      double k, t, t2, t3, nt1;
  1555. X  
  1556. X-     jyear(sdate, &yy, &mm, &dd);
  1557. X- 
  1558. X-     k = (yy + ((mm - 1) * (1.0 / 12.0)) - 1900) * 12.3685;
  1559. X- 
  1560. X      /* Time in Julian centuries from 1900 January 0.5 */
  1561. X      t = (sdate - 2415020.0) / 36525;
  1562. X      t2 = t * t;           /* Square for frequent use */
  1563. X
  1564. X--- 565,570 -----
  1565. X  {
  1566. X      double    t, t2, t3, nt1;
  1567. X  
  1568. X      /* Time in Julian centuries from 1900 January 0.5 */
  1569. X      t = (sdate - 2415020.0) / 36525;
  1570. X      t2 = t * t;           /* Square for frequent use */
  1571. X***************
  1572. X*** 459,465
  1573. X      t2 = t * t;           /* Square for frequent use */
  1574. X      t3 = t2 * t;           /* Cube for frequent use */
  1575. X  
  1576. X-     *usek = k = floor(k) + phase;
  1577. X      nt1 = 2415020.75933 + synmonth * k
  1578. X            + 0.0001178 * t2
  1579. X            - 0.000000155 * t3
  1580. X
  1581. X--- 570,575 -----
  1582. X      t2 = t * t;           /* Square for frequent use */
  1583. X      t3 = t2 * t;           /* Cube for frequent use */
  1584. X  
  1585. X      nt1 = 2415020.75933 + synmonth * k
  1586. X          + 0.0001178 * t2
  1587. X          - 0.000000155 * t3
  1588. X***************
  1589. X*** 461,469
  1590. X  
  1591. X      *usek = k = floor(k) + phase;
  1592. X      nt1 = 2415020.75933 + synmonth * k
  1593. X!           + 0.0001178 * t2
  1594. X!           - 0.000000155 * t3
  1595. X!           + 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);
  1596. X  
  1597. X      return nt1;
  1598. X  }
  1599. X
  1600. X--- 571,579 -----
  1601. X      t3 = t2 * t;           /* Cube for frequent use */
  1602. X  
  1603. X      nt1 = 2415020.75933 + synmonth * k
  1604. X!         + 0.0001178 * t2
  1605. X!         - 0.000000155 * t3
  1606. X!         + 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);
  1607. X  
  1608. X      return nt1;
  1609. X  }
  1610. X***************
  1611. X*** 468,477
  1612. X      return nt1;
  1613. X  }
  1614. X  
  1615. X- /*  TRUEPHASE  --  Given a K value used to determine the
  1616. X-            mean phase of the new moon, and a phase
  1617. X-            selector (0.0, 0.25, 0.5, 0.75), obtain
  1618. X-            the true, corrected phase time.  */
  1619. X  
  1620. X  static double truephase(k, phase)
  1621. X  double k, phase;
  1622. X
  1623. X--- 578,583 -----
  1624. X      return nt1;
  1625. X  }
  1626. X  
  1627. X  
  1628. X  /*
  1629. X   * TRUEPHASE  --  Given a K value used to determine the
  1630. X***************
  1631. X*** 473,480
  1632. X             selector (0.0, 0.25, 0.5, 0.75), obtain
  1633. X             the true, corrected phase time.  */
  1634. X  
  1635. X! static double truephase(k, phase)
  1636. X! double k, phase;
  1637. X  {
  1638. X      double t, t2, t3, pt, m, mprime, f;
  1639. X      int apcor = FALSE;
  1640. X
  1641. X--- 579,595 -----
  1642. X  }
  1643. X  
  1644. X  
  1645. X! /*
  1646. X!  * TRUEPHASE  --  Given a K value used to determine the
  1647. X!  *        mean phase of the new moon, and a phase
  1648. X!  *        selector (0.0, 0.25, 0.5, 0.75), obtain
  1649. X!  *        the true, corrected phase time.
  1650. X!  */
  1651. X! 
  1652. X! static
  1653. X! double
  1654. X! truephase(k, phase)
  1655. X!     double k, phase;
  1656. X  {
  1657. X      double t, t2, t3, pt, m, mprime, f;
  1658. X      int apcor = FALSE;
  1659. X***************
  1660. X*** 545,551
  1661. X         apcor = TRUE;
  1662. X      }
  1663. X      if (!apcor) {
  1664. X!            fprintf(stderr, "TRUEPHASE called with invalid phase selector.\n");
  1665. X         abort();
  1666. X      }
  1667. X      return pt;
  1668. X
  1669. X--- 660,667 -----
  1670. X         apcor = TRUE;
  1671. X      }
  1672. X      if (!apcor) {
  1673. X!            (void)fprintf (stderr,
  1674. X!         "TRUEPHASE called with invalid phase selector.\n");
  1675. X         abort();
  1676. X      }
  1677. X      return pt;
  1678. X***************
  1679. X*** 551,560
  1680. X      return pt;
  1681. X  }
  1682. X  
  1683. X- /*  PHASEHUNT  --  Find time of phases of the moon which surround
  1684. X-            the current date.  Five phases are found, starting
  1685. X-            and ending with the new moons which bound the
  1686. X-            current lunation.  */
  1687. X  
  1688. X  static void phasehunt(sdate, phases)
  1689. X  double sdate;
  1690. X
  1691. X--- 667,672 -----
  1692. X      return pt;
  1693. X  }
  1694. X  
  1695. X  
  1696. X  /*
  1697. X   * PHASEHUNT  --  Find time of phases of the moon which surround
  1698. X***************
  1699. X*** 556,564
  1700. X             and ending with the new moons which bound the
  1701. X             current lunation.  */
  1702. X  
  1703. X! static void phasehunt(sdate, phases)
  1704. X! double sdate;
  1705. X! double phases[5];
  1706. X  {
  1707. X      double adate, k1, k2, nt1, nt2;
  1708. X  
  1709. X
  1710. X--- 668,685 -----
  1711. X  }
  1712. X  
  1713. X  
  1714. X! /*
  1715. X!  * PHASEHUNT  --  Find time of phases of the moon which surround
  1716. X!  *        the current date.  Five phases are found, starting
  1717. X!  *        and ending with the new moons which bound the
  1718. X!  *        current lunation.
  1719. X!  */
  1720. X! 
  1721. X! static
  1722. X! void
  1723. X! phasehunt (sdate, phases)
  1724. X!     double    sdate;
  1725. X!     double    phases [5];
  1726. X  {
  1727. X      int    yy, mm, dd;
  1728. X      double    adate, k1, k2, nt1, nt2;
  1729. X***************
  1730. X*** 560,566
  1731. X  double sdate;
  1732. X  double phases[5];
  1733. X  {
  1734. X!     double adate, k1, k2, nt1, nt2;
  1735. X  
  1736. X      adate = sdate - 45;
  1737. X      nt1 = meanphase(adate, 0.0, &k1);
  1738. X
  1739. X--- 681,688 -----
  1740. X      double    sdate;
  1741. X      double    phases [5];
  1742. X  {
  1743. X!     int    yy, mm, dd;
  1744. X!     double    adate, k1, k2, nt1, nt2;
  1745. X  
  1746. X      adate = sdate - 45;
  1747. X      jyear(adate, &yy, &mm, &dd);
  1748. X***************
  1749. X*** 563,569
  1750. X      double adate, k1, k2, nt1, nt2;
  1751. X  
  1752. X      adate = sdate - 45;
  1753. X!     nt1 = meanphase(adate, 0.0, &k1);
  1754. X      while (TRUE) {
  1755. X         adate += synmonth;
  1756. X         nt2 = meanphase(adate, 0.0, &k2);
  1757. X
  1758. X--- 685,694 -----
  1759. X      double    adate, k1, k2, nt1, nt2;
  1760. X  
  1761. X      adate = sdate - 45;
  1762. X!     jyear(adate, &yy, &mm, &dd);
  1763. X!     k1 = floor((yy + ((mm - 1) * (1.0 / 12.0)) - 1900) * 12.3685);
  1764. X! 
  1765. X!     adate = nt1 = meanphase(adate, k1);
  1766. X      while (TRUE) {
  1767. X          adate += synmonth;
  1768. X          k2 = k1 + 1;
  1769. X***************
  1770. X*** 565,576
  1771. X      adate = sdate - 45;
  1772. X      nt1 = meanphase(adate, 0.0, &k1);
  1773. X      while (TRUE) {
  1774. X!        adate += synmonth;
  1775. X!        nt2 = meanphase(adate, 0.0, &k2);
  1776. X!        if (nt1 <= sdate && nt2 > sdate)
  1777. X!           break;
  1778. X!        nt1 = nt2;
  1779. X!        k1 = k2;
  1780. X      }
  1781. X      phases[0] = truephase(k1, 0.0);
  1782. X      phases[1] = truephase(k1, 0.25);
  1783. X
  1784. X--- 690,702 -----
  1785. X  
  1786. X      adate = nt1 = meanphase(adate, k1);
  1787. X      while (TRUE) {
  1788. X!         adate += synmonth;
  1789. X!         k2 = k1 + 1;
  1790. X!         nt2 = meanphase(adate, k2);
  1791. X!         if (nt1 <= sdate && nt2 > sdate)
  1792. X!             break;
  1793. X!         nt1 = nt2;
  1794. X!         k1 = k2;
  1795. X      }
  1796. X      phases[0] = truephase(k1, 0.0);
  1797. X      phases[1] = truephase(k1, 0.25);
  1798. X***************
  1799. X*** 579,585
  1800. X      phases[4] = truephase(k2, 0.0);
  1801. X  }
  1802. X  
  1803. X- /*  KEPLER  --    Solve the equation of Kepler.  */
  1804. X  
  1805. X  static double kepler(m, ecc)
  1806. X  double m, ecc;
  1807. X
  1808. X--- 705,710 -----
  1809. X      phases[4] = truephase(k2, 0.0);
  1810. X  }
  1811. X  
  1812. X  
  1813. X  /*
  1814. X   * KEPLER  --    Solve the equation of Kepler.
  1815. X***************
  1816. X*** 581,588
  1817. X  
  1818. X  /*  KEPLER  --    Solve the equation of Kepler.  */
  1819. X  
  1820. X! static double kepler(m, ecc)
  1821. X! double m, ecc;
  1822. X  {
  1823. X      double e, delta;
  1824. X  #define EPSILON 1E-6
  1825. X
  1826. X--- 706,719 -----
  1827. X  }
  1828. X  
  1829. X  
  1830. X! /*
  1831. X!  * KEPLER  --    Solve the equation of Kepler.
  1832. X!  */
  1833. X! 
  1834. X! static
  1835. X! double
  1836. X! kepler(m, ecc)
  1837. X!     double m, ecc;
  1838. X  {
  1839. X      double e, delta;
  1840. X  #define EPSILON 1E-6
  1841. X***************
  1842. X*** 589,597
  1843. X  
  1844. X      e = m = torad(m);
  1845. X      do {
  1846. X!        delta = e - ecc * sin(e) - m;
  1847. X!        e -= delta / (1 - ecc * cos(e));
  1848. X!     } while (abs(delta) > EPSILON);
  1849. X      return e;
  1850. X  }
  1851. X  
  1852. X
  1853. X--- 720,728 -----
  1854. X  
  1855. X      e = m = torad(m);
  1856. X      do {
  1857. X!         delta = e - ecc * sin(e) - m;
  1858. X!         e -= delta / (1 - ecc * cos(e));
  1859. X!     } while (abs (delta) > EPSILON);
  1860. X      return e;
  1861. X  }
  1862. X  
  1863. X***************
  1864. X*** 595,601
  1865. X      return e;
  1866. X  }
  1867. X  
  1868. X- /*  PHASE  --  Calculate phase of moon as a fraction:
  1869. X  
  1870. X      The argument is the time for which the phase is requested,
  1871. X      expressed as a Julian date and fraction.  Returns the terminator
  1872. X
  1873. X--- 726,731 -----
  1874. X      return e;
  1875. X  }
  1876. X  
  1877. X  
  1878. X  /*
  1879. X   * PHASE  --  Calculate phase of moon as a fraction:
  1880. X***************
  1881. X*** 597,610
  1882. X  
  1883. X  /*  PHASE  --  Calculate phase of moon as a fraction:
  1884. X  
  1885. X!     The argument is the time for which the phase is requested,
  1886. X!     expressed as a Julian date and fraction.  Returns the terminator
  1887. X!     phase angle as a percentage of a full circle (i.e., 0 to 1),
  1888. X!     and stores into pointer arguments the illuminated fraction of
  1889. X!         the Moon's disc, the Moon's age in days and fraction, the
  1890. X!     distance of the Moon from the centre of the Earth, and the
  1891. X!     angular diameter subtended by the Moon as seen by an observer
  1892. X!     at the centre of the Earth.
  1893. X  
  1894. X  */
  1895. X  
  1896. X
  1897. X--- 727,744 -----
  1898. X  }
  1899. X  
  1900. X  
  1901. X! /*
  1902. X!  * PHASE  --  Calculate phase of moon as a fraction:
  1903. X!  *
  1904. X!  *    The argument is the time for which the phase is requested,
  1905. X!  *    expressed as a Julian date and fraction.  Returns the terminator
  1906. X!  *    phase angle as a percentage of a full circle (i.e., 0 to 1),
  1907. X!  *    and stores into pointer arguments the illuminated fraction of
  1908. X!  *    the Moon's disc, the Moon's age in days and fraction, the
  1909. X!  *    distance of the Moon from the centre of the Earth, and the
  1910. X!  *    angular diameter subtended by the Moon as seen by an observer
  1911. X!  *    at the centre of the Earth.
  1912. X!  */
  1913. X  
  1914. X  static
  1915. X  double
  1916. X***************
  1917. X*** 606,621
  1918. X      angular diameter subtended by the Moon as seen by an observer
  1919. X      at the centre of the Earth.
  1920. X  
  1921. X! */
  1922. X! 
  1923. X! static double phase(pdate, pphase, mage, dist, angdia, sudist, suangdia)
  1924. X! double pdate;
  1925. X! double *pphase;            /* Illuminated fraction */
  1926. X! double *mage;               /* Age of moon in days */
  1927. X! double *dist;               /* Distance in kilometres */
  1928. X! double *angdia;            /* Angular diameter in degrees */
  1929. X! double *sudist;            /* Distance to Sun */
  1930. X! double *suangdia;                  /* Sun's angular diameter */
  1931. X  {
  1932. X  
  1933. X      double Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
  1934. X
  1935. X--- 740,755 -----
  1936. X   *    at the centre of the Earth.
  1937. X   */
  1938. X  
  1939. X! static
  1940. X! double
  1941. X! phase (pdate, pphase, mage, dist, angdia, sudist, suangdia)
  1942. X!     double    pdate;
  1943. X!     double    *pphase;        /* Illuminated fraction */
  1944. X!     double    *mage;            /* Age of moon in days */
  1945. X!     double    *dist;            /* Distance in kilometres */
  1946. X!     double    *angdia;        /* Angular diameter in degrees */
  1947. X!     double    *sudist;        /* Distance to Sun */
  1948. X!     double    *suangdia;        /* Sun's angular diameter */
  1949. X  {
  1950. X  
  1951. X      double    Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
  1952. X***************
  1953. X*** 618,628
  1954. X  double *suangdia;                  /* Sun's angular diameter */
  1955. X  {
  1956. X  
  1957. X!     double Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
  1958. X!            mEc, A4, lP, V, lPP, NP, y, x, Lambdamoon, BetaM,
  1959. X!            MoonAge, MoonPhase,
  1960. X!            MoonDist, MoonDFrac, MoonAng, MoonPar,
  1961. X!            F, SunDist, SunAng;
  1962. X  
  1963. X          /* Calculation of the Sun's position */
  1964. X  
  1965. X
  1966. X--- 752,762 -----
  1967. X      double    *suangdia;        /* Sun's angular diameter */
  1968. X  {
  1969. X  
  1970. X!     double    Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
  1971. X!         mEc, A4, lP, V, lPP, NP, y, x, Lambdamoon, BetaM,
  1972. X!         MoonAge, MoonPhase,
  1973. X!         MoonDist, MoonDFrac, MoonAng, MoonPar,
  1974. X!         F, SunDist, SunAng;
  1975. X  
  1976. X          /* Calculation of the Sun's position */
  1977. X  
  1978. X***************
  1979. X*** 626,636
  1980. X  
  1981. X          /* Calculation of the Sun's position */
  1982. X  
  1983. X!     Day = pdate - epoch;        /* Date within epoch */
  1984. X!     N = fixangle((360 / 365.2422) * Day); /* Mean anomaly of the Sun */
  1985. X!     M = fixangle(N + elonge - elongp);    /* Convert from perigee
  1986. X!                        co-ordinates to epoch 1980.0 */
  1987. X!     Ec = kepler(M, eccent);     /* Solve equation of Kepler */
  1988. X      Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
  1989. X      Ec = 2 * todeg(atan(Ec));   /* True anomaly */
  1990. X          Lambdasun = fixangle(Ec + elongp);  /* Sun's geocentric ecliptic
  1991. X
  1992. X--- 760,770 -----
  1993. X  
  1994. X          /* Calculation of the Sun's position */
  1995. X  
  1996. X!     Day = pdate - epoch;            /* Date within epoch */
  1997. X!     N = fixangle((360 / 365.2422) * Day);    /* Mean anomaly of the Sun */
  1998. X!     M = fixangle(N + elonge - elongp);    /* Convert from perigee
  1999. X!                          co-ordinates to epoch 1980.0 */
  2000. X!     Ec = kepler(M, eccent);            /* Solve equation of Kepler */
  2001. X      Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
  2002. X      Ec = 2 * todeg(atan(Ec));        /* True anomaly */
  2003. X          Lambdasun = fixangle(Ec + elongp);    /* Sun's geocentric ecliptic
  2004. X***************
  2005. X*** 632,640
  2006. X                         co-ordinates to epoch 1980.0 */
  2007. X      Ec = kepler(M, eccent);     /* Solve equation of Kepler */
  2008. X      Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
  2009. X!     Ec = 2 * todeg(atan(Ec));   /* True anomaly */
  2010. X!         Lambdasun = fixangle(Ec + elongp);  /* Sun's geocentric ecliptic
  2011. X!                            longitude */
  2012. X      /* Orbital distance factor */
  2013. X      F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
  2014. X      SunDist = sunsmax / F;        /* Distance to Sun in km */
  2015. X
  2016. X--- 766,774 -----
  2017. X                           co-ordinates to epoch 1980.0 */
  2018. X      Ec = kepler(M, eccent);            /* Solve equation of Kepler */
  2019. X      Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
  2020. X!     Ec = 2 * todeg(atan(Ec));        /* True anomaly */
  2021. X!         Lambdasun = fixangle(Ec + elongp);    /* Sun's geocentric ecliptic
  2022. X!                             longitude */
  2023. X      /* Orbital distance factor */
  2024. X      F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
  2025. X      SunDist = sunsmax / F;            /* Distance to Sun in km */
  2026. X***************
  2027. X*** 637,644
  2028. X                             longitude */
  2029. X      /* Orbital distance factor */
  2030. X      F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
  2031. X!     SunDist = sunsmax / F;        /* Distance to Sun in km */
  2032. X!         SunAng = F * sunangsiz;     /* Sun's angular size in degrees */
  2033. X  
  2034. X  
  2035. X          /* Calculation of the Moon's position */
  2036. X
  2037. X--- 771,778 -----
  2038. X                              longitude */
  2039. X      /* Orbital distance factor */
  2040. X      F = ((1 + eccent * cos(torad(Ec))) / (1 - eccent * eccent));
  2041. X!     SunDist = sunsmax / F;            /* Distance to Sun in km */
  2042. X!         SunAng = F * sunangsiz;        /* Sun's angular size in degrees */
  2043. X  
  2044. X  
  2045. X          /* Calculation of the Moon's position */
  2046. X***************
  2047. X*** 725,728
  2048. X      *suangdia = SunAng;
  2049. X      return fixangle(MoonAge) / 360.0;
  2050. X  }
  2051. X! #endif    /* NO_SUN_MOON */
  2052. X
  2053. X--- 859,862 -----
  2054. X      *suangdia = SunAng;
  2055. X      return fixangle(MoonAge) / 360.0;
  2056. X  }
  2057. X! #endif  /* NO_SUN_MOON */
  2058. END_OF_FILE
  2059. if test 52733 -ne `wc -c <'patches04b'`; then
  2060.     echo shar: \"'patches04b'\" unpacked with wrong size!
  2061. fi
  2062. # end of 'patches04b'
  2063. fi
  2064. echo shar: End of archive 2 \(of 4\).
  2065. cp /dev/null ark2isdone
  2066. MISSING=""
  2067. for I in 1 2 3 4 ; do
  2068.     if test ! -f ark${I}isdone ; then
  2069.     MISSING="${MISSING} ${I}"
  2070.     fi
  2071. done
  2072. if test "${MISSING}" = "" ; then
  2073.     echo You have unpacked all 4 archives.
  2074.     rm -f ark[1-9]isdone
  2075. else
  2076.     echo You still need to unpack the following archives:
  2077.     echo "        " ${MISSING}
  2078. fi
  2079. ##  End of shell archive.
  2080. exit 0
  2081.  
  2082.